import React from 'react';
import { Table, Modal, Tabs, Button, Icon, Radio, Form } from 'antd';
import moment from 'moment';
import { userId } from '@/constant';
import { connect } from 'dva';
import ReactEcharts from 'echarts-for-react';
const creator = (type, payload) => ({ type, payload });
const { TabPane } = Tabs;

const Pie = props => {
  const { lifeCycleData, pieVisible, togglePie } = props;
  const {legendData,seriesData}=props.lifeCycle;

  const getOption = () => {
    return {
    //   title: {
    //     text: '某站点用户访问来源',
    //     subtext: '纯属虚构',
    //     left: 'center',
    //   },
      tooltip: {
        trigger: 'item',
        formatter: '{a} <br/>{b} : {c} ({d}%)',
      },
      legend: {
        orient: 'vertical',
        left: 'left',
        data: legendData,
      },
      series: [
        {
          name: '时间分布',
          type: 'pie',
          radius: '55%',
          center: ['50%', '50%'],
          data: seriesData,
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)',
            },
          },
        },
      ],
    };
  };
  const title=(
      <div style={{display:'flex',justifyContent:'space-between',width:750}}>
          <span>人生轨迹</span>
          <span style={{fontSize:12}}>单位：(天)</span>
      </div>
  )
  return (
    <Modal title={title} visible={pieVisible} onCancel={togglePie} width={850} footer={null}>
      <ReactEcharts
        option={getOption()}
        notMerge={true}
        lazyUpdate={true}
        theme={'theme_name'}
        // onChartReady={this.onChartReadyCallback}
        // onEvents={EventsDict}
        // opts={}
      />
    </Modal>
  );
};

const WrappedPie = Form.create()(Pie);

export default connect(({ lifeCycle }) => ({ lifeCycle }))(
    WrappedPie,
);

